<?php
namespace service\services;
use  think\Db;


class CommonService
{

    public function __construct()
    {

    }



    /**
     * 获取用户的SESSION信息
     */
    public function getUserSession()
    {

        $user_info = session('userInfo');
        return $user_info;

    }

    /**
     * 获取用户ID.
     */
    public function getUserId()
    {
        $user_info = session('userInfo');
        $user_id = $user_info['user_id'];
        return $user_id;
    }


    /**
     * 销毁用户的session信息.
     */
    public function destroyUserSession()
    {
        session('userInfo', null);
    }

    /**
     * 设置用户的SESSION信息
     */
    public function setUserSessionInfo($data)
    {
        $user_data['username'] = $data['username'];
        $user_data['user_id'] = $data['user_id'];
        $user_data['topic_id'] = $data['topic_id'];
        session('userInfo', $user_data);
        session('username', $user_data['username']);

    }


}
